package com.im;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;

import com.im.util.Compressor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan
public class InfoManageApplication extends SpringBootServletInitializer {

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
		return builder.sources(InfoManageApplication.class);
	}

	@Override
	public void onStartup(ServletContext servletContext) throws ServletException {
		// TODO Auto-generated method stub
		// 获取系统的根路劲,用户压缩混淆js.css
		String realPath = servletContext.getRealPath("/");
		Compressor.realPath = realPath;
		super.onStartup(servletContext);
		
		//setRegisterErrorPageFilter(false);
	}

	public static void main(String[] args) {
		SpringApplication.run(InfoManageApplication.class, args);
	}

}
/**
 * 方式一：直接使用应用程序RUN 1.使用自带tomcat，注释一下pom.xml配置
 * <exclusions> <exclusion> <groupId>org.springframework.boot</groupId>
 * <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion>
 * </exclusions>
 *
 * 2.Application mian方法写入 SpringApplication.run(Application.class, args);
 * 注意：请求不带工程名，http://localhost:8080/sbcontroller/test
 *
 * 方式二：使用tomcat部署 1.Application extends SpringBootServletInitializer 2.override
 * function configure（） 3.builder.sources(Application.class); 4.修改pom。xml
 * <dependency> <groupId>org.springframework.boot</groupId>
 * <artifactId>spring-boot-starter-web</artifactId>
 * <exclusions> <exclusion> <groupId>org.springframework.boot</groupId>
 * <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion>
 * </exclusions> </dependency>
 * 注意：请求需要带工程名，http://localhost:8080/sb-web/sbcontroller/test
 */
